{include file='public/meta'}
<title>添加角色</title>
{css href='/static/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css'}
</head>
<style type="text/css">
  .row{margin-right:40px;}
</style>
<body>
<link href="/static/lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="cl pd-20">
	<form action="{:url('admin/member/do_groupadd')}" method="post" class="form form-horizontal" id="form-article-add" enctype="multipart/form-data">
    <input type="hidden" name="gid" value="{$data.gid}">
    <!-- 角色名 -->
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>角色名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="输入角色名" name="gname" value="{$data.gname}" required>
			</div>
		</div>
    <!-- 描述 -->
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>描述：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="角色描述" name="des" value="{$data.des}" required>
			</div>
		</div>
    <!-- 权限 -->
    <div class="row cl">
      <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>权限：</label>
      <div class="formControls col-xs-8 col-sm-9 skin-minimal">
        {volist name="role" id="vo"}
        
        <fieldset>  
          <legend>{$key}</legend>
          {volist name="vo" id="v"}
          <div class="check-box">
            <input name="rid[]" type="checkbox" id="ck-{$v.rid}" {if condition="in_array($v.rid,$rid2s)"}checked{/if} value="{$v.rid}" required>
            <label for="ck-{$v.rid}">{$v.rname}</label>
          </div>
          {/volist}
        </fieldset>
        {/volist}
      </div>
    </div>
    <!-- 按钮 -->
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-primary radius" id="submit" type="submit"><i class="Hui-iconfont">&#xe632;</i> 修改</button>
			</div>
		</div>
	</form>
</div>
{include file='public/footer'}
  <script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
  <script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/validate-methods.js"></script> 
  <script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/messages_zh.js"></script> 
  <script type="text/javascript" src="/static/lib/webuploader/0.1.5/webuploader.min.js"></script> 
  <script type="text/javascript" src="/static/lib/ueditor/1.4.3/ueditor.config.js"></script>
  <script type="text/javascript" src="/static/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
  <script type="text/javascript" src="/static/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>

<script type="text/javascript">
  $().ready(function(){
  	$('form').validate({
      rules:{

      },
  		messages:{
        gname:{
          required:'必填字段',
        },
        des:{
          required:'必填字段',
        },
        rid:{
          required:'必填字段',
        },
      },
  		submitHandler:function(form){
        $(form).ajaxSubmit({
          type:'post',
          url:'{:url('admin/member/do_groupedit')}',
          dataType:'text',
          success:function(res){
            res = eval('('+res+')');
            console.log(res.msg);
            if(res.msg == '成功'){
              layer.msg('修改成功!',{icon:1,time:2000},function(){
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);  
              });
              // location.reload();
            }else{
              layer.msg(res.msg+'!',{icon:1,time:2000});
            }
            // layer_close();
          }
  			})
  		}
  	});
  })

  $(function(){
  	$('.skin-minimal input').iCheck({
  		checkboxClass: 'icheckbox-blue',
  		radioClass: 'iradio-blue',
  		increaseArea: '20%'
  	});
  });

</script>
</body>
</html>